import * as vscode from "vscode";
import selectBox3Map, {
  selectBox3MapExpandDetail,
} from "@ap/user/map/getMapList";
import { userCenterToolShowBar } from "@ap/user/userCenterTool";
import {
  login,
  loginInput,
  logout,
  openLoginSetting,
} from "@ap/user/accountsLogin";
import box3MapView from "@ap/webView/dao3map";
import selectBox3PlayMap from "@ap/user/map/getPlayMap";
import { buildNUpload } from "@ap/tools/compile";
import createProject from "@ap/util/mapFile/createProject";
import checkDts from "@ap/util/mapFile/checkDts";
import selectBox3Comment from "@ap/user/message/getCommentList";
import selectBox3SysComment from "@ap/user/message/getSysMsgList";
import chatjptLogView from "@ap/webView/chatjptLog";
import sendCodeToAi, {
  openChatjptSetting,
} from "@ap/util/aiCodeInteraction/menus";
import {
  ChatjptFunctionProvider,
  highlightCodeLinesFunction,
} from "@ap/util/aiCodeInteraction/functionDecorator";
import { dao3CfgProvider } from "@ap/util/mapFile/dao3CfgQuick";
import { ChatjptCodeActionProvider } from "@ap/util/aiCodeInteraction/quickFix";
import { setChatjptConfig, ChatjptViewModel } from "@ap/webView/chatjpt";
import { OutputChannel } from "@ap/util/vscode/output";
import { ConfigurationItem } from "@ap/util/vscode/setInsConfig";
import { outputAndUpdateShowBar } from "@ap/util/mapFile/setOutputAndUpdate";
import MapTreeDataProvider from "@ap/util/mapFile/tree/expandMap";
import TempChatPlayMapTreeDataProvider from "@ap/util/mapFile/tree/tempChatPlayMap";
import ModelsMapTreeDataProvider from "@ap/util/mapFile/tree/modelsMap";
import UiMapTreeDataProvider from "@ap/util/mapFile/tree/uiMap";
import PhotoMapTreeDataProvider from "@ap/util/mapFile/tree/photoMap";
import selectBox3MapTempChatDetail from "@ap/user/map/getMapTempChatList";
import insertCode from "@ap/util/vscode/insertCode";
import openAndWriteTextDocument, {
  openFileDocument,
  openTempFileDocument,
} from "@ap/util/vscode/openAndWriteTextDocument";
import openInternetImage from "@ap/webView/img";
import openFileSelected from "@ap/user/map/uploadFile";
import { setBox3MapPhoto } from "@ap/user/map/setMapData";
import { getPackageJson } from "@ap/util/packageJson";
import { openNodeSetting, PackageConfig } from "@ap/types/config";
import {
  getBox3MapModelList,
  getModelConfig,
  getModelCount,
  renameModel,
} from "@ap/user/map/getMapModelList";
import { auth, apiAndPCType, apiType, userData, ua } from "@ap/util/request";
import {
  showInformationMessage,
  deleteMapDataStorageDataNullMsg,
  showWarningMessage,
} from "@ap/util/vscode/message";
import StorageMapTreeDataProvider from "@ap/util/mapFile/tree/storageMap";
import AudioMapTreeDataProvider from "@ap/util/mapFile/tree/audioMap";
import {
  getDataConfig,
  getDataCount,
  getMapStorageList,
  isValidJson,
  storageData,
} from "@ap/user/map/getMapStorage";
import {
  deleteMapStorageKey,
  setMapStorageValue,
  warmDataStorageConfig,
} from "@ap/user/map/setMapStorage";
import openInternetAudio from "@ap/webView/audio";
import {
  RGBAColorProvider,
  Vec3ColorProvider,
  XMLColorColorProvider,
} from "@ap/util/colorProvider";
import { startHMR, stopHMR, stopHMRAll } from "@ap/tools/hmr";
import { upLoadJsFileType } from "@ap/util/mapFile/upLoadJsFileType";
import {
  ArenaDebugConfigProvider,
  ArenaProDebugConfigProvider,
  fastDebugger,
} from "@ap/util/debug/config";
import downloadNPMPackage from "@ap/npmPackage/downloadNPMPackage";
import ProductMapTreeDataProvider from "@ap/util/mapFile/tree/productMap";
import PlayerSkinMapTreeDataProvider from "@ap/util/mapFile/tree/playerSkinMap";
import VoxelMapTreeDataProvider from "@ap/util/mapFile/tree/voxelMap";
import { getPathAndFileName2Config } from "@ap/util/vscode/getPathAndFileName2Config";
import { selectNPMPackagePath } from "@ap/util/vscode/setPackage";
import { npmSearchShowBar } from "@ap/npmPackage/getnNPMPackage";
import { getResourceAll } from "@ap/user/map/getGroupProject";
import { createTempFile } from "@ap/util/vscode/tempFile";
import {
  ComponentUsageCodeLensProvider,
  showComponentReferences,
  showComponentStats,
  showMethodReferences,
  showPropertyReferences,
} from "@ap/util/mapFile/componentUsageProvider";
import { registerCommand } from "./events";
import { onlyKnowledgeBase } from "./webView/chatDialog";
const mapTreeDataProvider = new MapTreeDataProvider();
const modelsMapTreeDataProvider = new ModelsMapTreeDataProvider();
const uiMapTreeDataProvider = new UiMapTreeDataProvider();
const photoMapTreeDataProvider = new PhotoMapTreeDataProvider();
const audioMapTreeDataProvider = new AudioMapTreeDataProvider();
export const storageMapTreeDataProvider = new StorageMapTreeDataProvider();
const tempChatEditMapTreeDataProvider = new TempChatPlayMapTreeDataProvider();
const productMapTreeDataProvider = new ProductMapTreeDataProvider();
const playerSkinMapTreeDataProvider = new PlayerSkinMapTreeDataProvider();
const voxelMapTreeDataProvider = new VoxelMapTreeDataProvider();

export let voxelMap: vscode.TreeView<any>,
  storageMap: vscode.TreeView<any>,
  expandMap: vscode.TreeView<any>,
  uiMap: vscode.TreeView<any>,
  modelsMap: vscode.TreeView<any>,
  photoMap: vscode.TreeView<any>,
  audioMap: vscode.TreeView<any>,
  tempChatEditMap: vscode.TreeView<any>,
  productMap: vscode.TreeView<any>,
  playerSkinMap: vscode.TreeView<any>;

const bodyParts = [
  "hips",
  "torso",
  "neck",
  "head",
  "leftShoulder",
  "leftUpperArm",
  "leftLowerArm",
  "leftHand",
  "leftUpperLeg",
  "leftLowerLeg",
  "leftFoot",
  "rightShoulder",
  "rightUpperArm",
  "rightLowerArm",
  "rightHand",
  "rightUpperLeg",
  "rightLowerLeg",
  "rightFoot",
];

/**
 * 命令标识符枚举，用于定义和识别不同的操作命令。
 * 每个命令标识符代表一个特定的操作或功能，通过这些标识符可以触发相应的操作。
 */
export enum CommandId {
  // 插件激活管理
  ap_activated = "ap.activated",
  // 显示vscode文件资源管理器
  ap_files_focusFilesExplorer = "workbench.files.action.focusFilesExplorer",
  // 打开设置界面
  ap_openSettings = "workbench.action.openSettings",
  // ──── 用户中心工具 ───────────────────────────────────────────
  // 显示用户管理选择框
  userCenterTool_showBar = "ap.userCenterTool.showBar",
  // 获取用户账户Token和用户代理UA
  userCenterTool_userTokenAndUA = "ap.userCenterTool.userTokenAndUA",
  // 获取用户信息
  userCenterTool_userInfo = "ap.userCenterTool.userInfo",
  // 神岛账号登录
  userCenterTool_accountsLogin = "ap.userCenterTool.accountsLogin",
  // 神岛账号登出
  userCenterTool_accountsLogout = "ap.userCenterTool.accountsLogout",
  // 账号评论我的
  userCenterTool_comment = "ap.userCenterTool.comment",
  // 账户系统评论
  userCenterTool_sysComment = "ap.userCenterTool.sysComment",
  // 神岛API文档
  userCenterTool_api_help = "ap.userCenterTool.api.help",
  userCenterTool_arenaPro_Help = "ap.userCenterTool.arenaPro.help",
  // 打开神岛用户设置界面
  userCenterTool_setting = "ap.setting.userCenterTool",

  // ──── 项目文件工具 ───────────────────────────────────────────
  // 显示神岛NPM包
  file_npm_package_get = "ap.file.npm.package.get",
  // 配置该输出上传指定文件名称，打开选择框
  file_outputName = "ap.file.outputName",
  // 配置该项目至扩展地图，打开选择框
  file_mapTool = "ap.file.mapTool",
  // 上传Ts项目并打包
  file_buildNUpload = "ap.file.buildNUpload",
  // 创建Ts脚手架
  file_createProject = "ap.file.createProject",
  // 检查项目d.ts文件版本
  file_checkDts = "ap.file.checkDts",
  // 调起NodeJs相关设置界面
  file_nodeJs_setting = "ap.file.nodeJs.setting",
  // 显示Arena资源管理器
  file_openArena = "ap.file.openArena",
  // 激活并显示Arena资源管理器
  file_workbench = "workbench.view.extension.arenaExplorer",
  // 停止webpack hmr
  file_stopHMR = "ap.file.hmr.stop",
  // 重启webpack hmr
  file_reHMR = "ap.file.hmr.reStart",
  // 停止全部webpack hmr
  file_stopHMRAll = "ap.file.hmr.stopAll",
  // 上传js文件至神岛编辑器
  file_upLoad = "ap.file.upLoad",
  // 快速Debugger js文件
  file_debugger = "ap.file.debugger",
  // 打开ArenaPro输出日志
  file_openOutputLog = "ap.file.outputLog",
  // 打开dao3.config.json
  file_dao3config_open = "ap.file.dao3config.open",
  // 打开dao3.config.json 服务端入口文件
  file_dao3config_open_server = "ap.file.dao3config.open.server",
  // 打开dao3.config.json 客户端文件
  file_dao3config_open_client = "ap.file.dao3config.open.client",
  // 打开webpackconfig客户端文件
  file_webpackconfig_open_client = "ap.file.webpackconfig.open.client",
  // 打开webpackconfig服务端文件
  file_webpackconfig_open_server = "ap.file.webpackconfig.open.server",
  // 打开tsconfig客户端文件
  file_tsconfig_open_client = "ap.file.tsconfig.open.client",
  // 打开tsconfig服务端文件
  file_tsconfig_open_server = "ap.file.tsconfig.open.server",
  // 设置神岛npm包的路径
  file_npm_package_path = "ap.file.npm.package.path",

  // ──── 地图查看工具 ───────────────────────────────────────────
  // 显示该地图项目创作端
  map_showMap = "ap.map.showMap",
  // 查看该项目游玩数据
  map_playData = "ap.map.playData",
  // 一键同步地图所有资源
  map_resource = "ap.map.resource",
  // 获取组数据空间树视图
  map_treeDataMapLinkGroupStorage = "ap.map.treeData.dataStorage.group.link",
  // 获取普通数据空间树视图
  map_treeDataMapLinkDataStorage = "ap.map.treeData.dataStorage.link",
  // 新增数据空间键值对树视图
  map_treeDataMapNewDataStorageKey = "ap.map.treeData.dataStorage.new.data",
  // 数据空间数据下一页
  map_treeDataMapDataStorageNext = "ap.map.treeData.dataStorage.next.data",
  // 数据空间数据上一页
  map_treeDataMapDataStoragePrevious = "ap.map.treeData.dataStorage.previous.data",
  // 模型数据下一页
  map_treeDataMapDataModelsNext = "ap.map.treeData.models.next.data",
  // 模型数据上一页
  map_treeDataMapDataModelsPrevious = "ap.map.treeData.models.previous.data",
  // 约束数据空间目标值
  map_treeDataMapDataStorageTarget = "ap.map.treeData.dataStorage.constraint.target",
  // 数据空间升序
  map_treeDataMapDataStorageAscending = "ap.map.treeData.dataStorage.constraint.ascending",
  // 数据空间降序
  map_treeDataMapDataStorageDescending = "ap.map.treeData.dataStorage.constraint.descending",
  // 模型按创建时间倒序
  map_treeDataMapDataModelsOrderBy0 = "ap.map.treeData.models.orderBy.0",
  // 模型按名称排序
  map_treeDataMapDataModelsOrderBy1 = "ap.map.treeData.models.orderBy.1",
  // 模型按修改时间倒序
  map_treeDataMapDataModelsOrderBy2 = "ap.map.treeData.models.orderBy.2",
  // 数据空间数值区间设置
  map_treeDataMapDataStorageRange = "ap.map.treeData.dataStorage.constraint.range",
  // 查看数据空间配置
  map_treeDataMapDataStorageConfig = "ap.map.preview.dataStorage.config",
  // 查看数据空间值数据
  map_preview_dataStorage_value = "ap.map.preview.dataStorage.value",
  // 刷新Arena数据空间树视图
  map_treeDataMapDataStorageRefresh = "ap.map.treeData.dataStorage.refresh",
  // 获取Arena数据空间树视图
  map_treeDataMapDataStorageData = "ap.map.treeData.dataStorage.data",
  // 刷新Arena音频树视图
  map_treeDataMapAudioRefresh = "ap.map.treeData.audio.refresh",
  // 插入Arena音频路径树处理
  map_insertCode_audio = "ap.map.insertCode.audio",
  // 查看Arena音频预览图树处理
  map_preview_audio = "ap.map.preview.audio",
  // 复制Arena音频预览图树处理
  map_copy_url_audio = "ap.map.copy.url.audio",
  // 刷新扩展地图树视图
  map_treeDataMapRefresh = "ap.map.treeData.refresh",
  // 刷新Arena界面树视图
  map_treeDataMapUiRefresh = "ap.map.treeData.ui.refresh",
  // 刷新Arena模型树视图
  map_treeDataMapModelsRefresh = "ap.map.treeData.models.refresh",
  // 刷新Arena图片树视图
  map_treeDataMapPhotoRefresh = "ap.map.treeData.photo.refresh",
  // 刷新Arena商城树视图
  map_treeDataMapProductRefresh = "ap.map.treeData.product.refresh",
  // 刷新Arena玩家皮肤树视图
  map_treeDataMapPlayerSkinRefresh = "ap.map.treeData.playerSkin.refresh",
  // 刷新Arena图片临时聊天频道视图
  map_treeDataMapTempChatEditRefresh = "ap.map.treeData.tempChatEdit.refresh",
  // Arena图片上传处理
  map_treeDataMapPhotoUpload = "ap.map.treeData.photo.upload",
  // Arena扩展地图树处理
  map_treeDataExpandMapUpload = "ap.map.treeDataExpandMapUpload",
  // Arena临时频道树处理
  map_selectBox3MapTempChatDetail = "ap.map.selectBox3MapTempChatDetail",
  // ArenaUI元素配置项处理
  map_preview_ui_config = "ap.map.preview.ui.config",
  // 插入Arena模型路径树处理
  map_insertCode_model = "ap.map.insertCode.model",
  // 查看Arena模型预览图树处理
  map_preview_model = "ap.map.preview.model",
  // 查看Arena模型文件树处理
  map_model_view = "ap.map.model.view",
  // 查看Arena玩家皮肤模型文件
  map_model_playerSkin_view = "ap.map.model.playerSkin.view",
  // 重命名Arena模型文件树处理
  map_model_rename = "ap.map.model.rename",
  // 插入Arena图片路径树处理
  map_insertCode_photo = "ap.map.insertCode.photo",
  // 插入ArenaUI完整路径树处理
  map_insertCode_uiFullPath = "ap.map.insertCode.uiFullPath",
  // 插入ArenaUI路径树处理
  map_insertCode_uiPath = "ap.map.insertCode.uiPath",
  // 查看Arena图片预览图树处理
  map_preview_photo = "ap.map.preview.photo",
  // 复制Arena图片直链接树处理
  map_copy_url_photo = "ap.map.copy.url.photo",
  // 插入Arena临时频道ID树处理
  map_insertCode_tempChat = "ap.map.insertCode.tempChat",
  // 插入Arena扩展地图ID树处理
  map_insertCode_expandMap = "ap.map.insertCode.expand",
  // 插入Arena玩家皮肤ID树处理
  map_insertCode_playerSkin = "ap.map.insertCode.playerSkin",
  // 插入Arena清除玩家皮肤树处理
  map_insertCode_playerSkin_trash = "ap.map.insertCode.playerSkin.trash",
  // 插入Arena玩家皮肤套装树处理
  map_insertCode_playerSkin_all = "ap.map.insertCode.playerSkin.all",
  // 插入Arena方块名称转ID树处理
  map_insertCode_voxel_nameToId = "ap.map.insertCode.voxel.nameToId",
  // 插入Arena方块ID转名称树处理
  map_insertCode_voxel_idToName = "ap.map.insertCode.voxel.idToName",
  // 插入Arena方块名树处理
  map_insertCode_voxel = "ap.map.insertCode.voxel",
  // 查看Arena扩展地图创作端树处理
  map_expandMap_view = "ap.map.expandMap.view",
  // 查看Arena地图商城创作端树处理
  map_preview_product = "ap.map.preview.product",
  // 查看Arena地图玩家皮肤创作端树处理
  map_preview_playerSkin = "ap.map.preview.playerSkin",
  // 插入Arena地图商城ID创作端树处理
  map_insertCode_productMap = "ap.map.insertCode.product",
  // 插入Arena地图商城ID完整路径创作端树处理
  map_insertCode_productMapFullPath = "ap.map.insertCode.productFullPath",
  // 搜索Arena方块资源创作端树处理
  map_treeDataMapVoxelSearch = "ap.map.treeData.voxel.search",

  // 复制Arena扩展地图游玩端直链树处理
  map_copy_url_expandMap_play = "ap.map.copy.url.expandMap.play",
  // ──── Chat吉PT AI工具 ───────────────────────────────────────────
  // 激活并显示Chatjpt窗口
  chatjpt_workbench = "workbench.view.extension.chatjpt",
  // 激活快速询问功能
  chatjpt_fastFunction_activated = "ap.chatjpt.code.fastFunction.activated",
  // 调起Chat吉PT设置界面
  chatjpt_setting = "ap.chatjpt.setting",
  // 查看Chat吉PT对话日志
  chatjpt_history = "ap.chatjpt.history",

  // 仅查询知识库
  chatjpt_onlyKnowledgeBase = "ap.chatjpt.onlyKnowledgeBase",

  // 快速修复代码
  chatjpt_quickFix = "ap.chatjpt.code.quickFix",
  // Debug代码
  chatjpt_debug = "ap.chatjpt.code.debug",
  // 优化重构
  chatjpt_optimization = "ap.chatjpt.code.optimization",
  // 详细解释
  chatjpt_explainDetail = "ap.chatjpt.code.explainDetail",
  // 注释生成
  chatjpt_commentGeneration = "ap.chatjpt.code.commentGeneration",
  // 自然语言生成
  chatjpt_naturalLanguageGenerates = "ap.chatjpt.code.naturalLanguageGenerates",
  // API详细解释和示例
  chatjpt_APIdetailedExplanationsAndExamples = "ap.chatjpt.code.APIdetailedExplanationsAndExamples",
  // 衍生更多灵感和创意
  chatjpt_generateInspirationAndCreativity = "ap.chatjpt.code.generateInspirationAndCreativity",
  // 拆分知识点并命题
  chatjpt_splitKnowledge = "ap.chatjpt.code.splitKnowledge",
  // 快速选择代码
  chatjpt_fastFunction = "ap.chatjpt.code.fastFunction",
  // 注释生成
  chatjpt_git = "ap.chatjpt.git",

  // ──── ECS架构 ───────────────────────────────────────────
  // 注册属性
  codelens_showPropertyReferences = "ap.codelens.showPropertyReferences",
  // 注册方法
  codelens_showMethodReferences = "ap.codelens.showMethodReferences",
  // 注册类
  codelens_showComponentReferences = "ap.codelens.showComponentReferences",
  // 显示组件统计
  component_showComponentStats = "ap.component.stats",
}

/**
 * 注册所有扩展命令到VS Code。
 * @param context VS Code扩展上下文，用于管理扩展的生命周期和订阅事件。
 */
export function registerAllCommands(context: vscode.ExtensionContext): void {
  context.subscriptions.push(
    registerCommand(
      CommandId.codelens_showPropertyReferences,
      "显示组件属性引用",
      showPropertyReferences,
    ),
    registerCommand(
      CommandId.codelens_showMethodReferences,
      "显示组件方法引用",
      showMethodReferences,
    ),
    registerCommand(
      CommandId.codelens_showComponentReferences,
      "显示组件引用",
      showComponentReferences,
    ),
    registerCommand(
      CommandId.component_showComponentStats,
      "显示组件统计",
      showComponentStats,
    ),

    registerCommand(
      CommandId.userCenterTool_userTokenAndUA,
      "获取神岛用户Token和用户代理(userAgent)",
      () => {
        return {
          nickname: userData?.data?.nickname,
          userId: userData?.data?.userId,
          token: auth,
          userAgent: ua,
        };
      },
    ),
    registerCommand(
      CommandId.userCenterTool_userInfo,
      "获取神岛用户信息",
      () => userData,
    ),
    registerCommand(
      CommandId.userCenterTool_accountsLogout,
      "神岛账号登出",
      logout,
    ),
    registerCommand(
      CommandId.userCenterTool_comment,
      "评论",
      selectBox3Comment,
    ),
    registerCommand(
      CommandId.userCenterTool_sysComment,
      "系统评论",
      selectBox3SysComment,
    ),
    registerCommand(
      CommandId.userCenterTool_showBar,
      "显示用户管理选择框",
      userCenterToolShowBar,
    ),
    registerCommand(
      CommandId.userCenterTool_accountsLogin,
      "神岛账号登录",
      loginInput,
    ),
    registerCommand(
      CommandId.userCenterTool_setting,
      "用户设置",
      openLoginSetting,
    ),
    registerCommand(
      CommandId.chatjpt_setting,
      "Chat吉PT设置",
      openChatjptSetting,
    ),
    registerCommand(
      CommandId.file_nodeJs_setting,
      "NodeJs设置",
      openNodeSetting,
    ),

    // 注册帮助命令，打开API在线文档。
    registerCommand(CommandId.userCenterTool_api_help, "API在线文档", () => {
      vscode.env.openExternal(
        vscode.Uri.parse("https://docs.box3lab.com/api/"),
      );
    }),
    // 注册帮助命令，打开插件帮助文档。
    registerCommand(
      CommandId.userCenterTool_arenaPro_Help,
      "ArenaPro帮助文档",
      () => {
        vscode.env.openExternal(
          vscode.Uri.parse("https://docs.box3lab.com/arenapro/"),
        );
      },
    ),

    // 注册地图相关命令。
    registerCommand(CommandId.map_showMap, "显示该地图项目创作端", box3MapView),
    registerCommand(
      CommandId.map_playData,
      "查看该项目游玩数据",
      selectBox3PlayMap,
    ),
    registerCommand(
      CommandId.map_resource,
      "一键同步地图所有资源",
      getResourceAll,
    ),

    registerCommand(
      CommandId.file_npm_package_path,
      "设置神岛NPM包的路径",
      selectNPMPackagePath,
    ),

    registerCommand(
      CommandId.map_treeDataMapRefresh,
      "刷新Arena数据空间树视图",
      () => {
        mapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapUiRefresh,
      "刷新Arena界面树视图",
      () => {
        uiMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapModelsRefresh,
      "刷新Arena模型树视图",
      () => {
        modelsMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapPhotoRefresh,
      "刷新Arena图片树视图",
      () => {
        photoMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapTempChatEditRefresh,
      "刷新Arena临时频道树视图",
      () => {
        tempChatEditMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapAudioRefresh,
      "刷新Arena音频树视图",
      () => {
        audioMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapProductRefresh,
      "刷新Arena商城树视图",
      () => {
        productMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapPlayerSkinRefresh,
      "刷新Arena玩家皮肤树视图",
      () => {
        playerSkinMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapVoxelSearch,
      "搜索Arena方块资源",
      () => {
        voxelMapTreeDataProvider.dataBySearchShowBar();
      },
    ),
    //map_treeDataMapVoxelSearch
    registerCommand(
      CommandId.map_treeDataMapDataStorageRefresh,
      "刷新Arena数据空间树视图",
      () => {
        getMapStorageList().then(() => {
          storageMapTreeDataProvider.refresh();
        });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapNewDataStorageKey,
      "新增Arena数据空间键",
      async (ev) => {
        if (!warmDataStorageConfig()) {
          return;
        }
        let key = await vscode.window.showInputBox({
          title: "【新增】键",
          prompt: "请输入新键名，支持字符串类型。",
        });
        if (!key) {
          return;
        }
        const selectedOption = await vscode.window.showQuickPick(
          [
            {
              label: "JSON对象",
              value: true,
            },
            {
              label: "非JSON对象（如字符串、数字、布尔值）",
              value: false,
            },
          ],
          {
            title: "【新增】请选择值的类型",
            matchOnDescription: true,
            canPickMany: false,
          },
        );
        if (selectedOption) {
          const modifiedDoc = await createTempFile(
            "",
            key +
              " - Arena数据空间" +
              (selectedOption.value ? ".json" : ".txt"),
          );
          openTempFileDocument(modifiedDoc);
        }
      },
    ),

    registerCommand(
      CommandId.file_npm_package_get,
      "搜索神岛NPM包",
      npmSearchShowBar,
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageTarget,
      "设置数据空间约束目标路径",
      () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        vscode.window
          .showInputBox({
            title: "数据空间：设置约束目标路径",
            placeHolder: "a.b.c.d.e",
            prompt: `约束目标值的路径，当值是JSON格式时，指定用作排序的值的路径。例如传入score时，会取值上score属性的值作为排序、 区间的限制目标； 级联最多5级，`,
          })
          .then(async (target) => {
            if (target) {
              getDataConfig.constraint.target = target;
              await getMapStorageList();
              storageMapTreeDataProvider.refresh();
            }
          });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageData,
      "打开数据空间数据",
      async () => {
        openAndWriteTextDocument({
          language: "json",
          content: JSON.stringify(storageData),
          viewColumn: vscode.ViewColumn.Two,
        });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageDescending,
      "数据空间数据降序",
      async () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        getDataConfig.constraint.ascending = true;
        await getMapStorageList();
        storageMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageNext,
      "数据空间数据下一页",
      async () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        if (getDataCount - (getDataConfig.offset + 50) <= 0) {
          showInformationMessage("已到最后页");
          return;
        }
        getDataConfig.offset += 50;
        await getMapStorageList();
        storageMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStoragePrevious,
      "数据空间数据上一页",
      async () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        if (getDataConfig.offset <= 0) {
          showInformationMessage("已到最前页");
          return;
        }
        getDataConfig.offset -= 50;
        getDataConfig.offset = Math.max(0, getDataConfig.offset);
        await getMapStorageList();
        storageMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataModelsOrderBy0,
      "模型数据按创建时间倒序",
      async () => {
        if (getModelConfig.orderBy === 0) {
          showInformationMessage("当前模型已经是按创建时间倒序。");
          return;
        }
        getModelConfig.orderBy = 0;
        await getBox3MapModelList();
        modelsMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataModelsOrderBy1,
      "模型数据按名称排序",
      async () => {
        if (getModelConfig.orderBy === 1) {
          showInformationMessage("当前模型已经是按名称排序。");
          return;
        }
        getModelConfig.orderBy = 1;
        await getBox3MapModelList();
        modelsMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataModelsOrderBy2,
      "模型数据按修改时间倒序",
      async () => {
        if (getModelConfig.orderBy === 2) {
          showInformationMessage("当前模型已经是按修改时间倒序。");
          return;
        }
        getModelConfig.orderBy = 2;
        await getBox3MapModelList();
        modelsMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataModelsNext,
      "模型数据下一页",
      async () => {
        if (getModelCount - (getModelConfig.offset + 50) <= 0) {
          showInformationMessage("已到最后页");
          return;
        }
        getModelConfig.offset += 50;
        await getBox3MapModelList();
        modelsMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataModelsPrevious,
      "模型数据上一页",
      async () => {
        if (getModelConfig.offset <= 0) {
          showInformationMessage("已到最前页");
          return;
        }
        getModelConfig.offset -= 50;
        getModelConfig.offset = Math.max(0, getModelConfig.offset);
        await getBox3MapModelList();
        modelsMapTreeDataProvider.refresh();
      },
    ),

    registerCommand(
      CommandId.map_treeDataMapDataStorageAscending,
      "数据空间数据升序",
      async () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        getDataConfig.constraint.ascending = false;
        await getMapStorageList();
        storageMapTreeDataProvider.refresh();
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageRange,
      "数据空间数据范围",
      () => {
        if (!warmDataStorageConfig()) {
          return;
        }
        vscode.window
          .showInputBox({
            title: "数据空间：设置数据闭区间范围",
            prompt: "过滤超出闭区间的数值；格式为：[min,max]",
            value: `[${getDataConfig.constraint.min ?? 0},${getDataConfig.constraint.max ?? 100}]`,
          })
          .then(async (value) => {
            if (value) {
              const regex = /^\[\s*(-?\d+)\s*,\s*(-?\d+)\s*\]$/;
              const match = value.match(regex);
              if (!match) {
                showWarningMessage("输入格式错误，请输入有效的区间范围！");
                return;
              }
              const [min, max] = match.slice(1).map(Number);
              getDataConfig.constraint.min = min;
              getDataConfig.constraint.max = max;
              await getMapStorageList();
              storageMapTreeDataProvider.refresh();
            }
          });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapLinkGroupStorage,
      "链接组数据空间",
      (ev) => {
        vscode.window
          .showInputBox({
            title: "数据空间",
            prompt: "请输入当前地图下的“组”数据空间名称",
          })
          .then((storageName) => {
            if (storageName) {
              getMapStorageList({
                storageName,
                isGroup: true,
                offset: 0,
                constraint: {},
              }).then(() => {
                storageMapTreeDataProvider.refresh();
              });
            }
          });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapLinkDataStorage,
      "链接普通数据空间",
      () => {
        vscode.window
          .showInputBox({
            title: "数据空间",
            prompt: "请输入当前地图下的“普通”数据空间名称",
          })
          .then((storageName) => {
            if (storageName) {
              getMapStorageList({
                storageName,
                isGroup: false,
                offset: 0,
                constraint: {},
              }).then(() => {
                storageMapTreeDataProvider.refresh();
              });
            }
          });
      },
    ),
    registerCommand(
      CommandId.map_treeDataExpandMapUpload,
      "扩展地图上传",
      selectBox3MapExpandDetail,
    ),
    registerCommand(
      CommandId.map_selectBox3MapTempChatDetail,
      "选择扩展地图临时聊天",
      selectBox3MapTempChatDetail,
    ),
    registerCommand(CommandId.map_treeDataMapPhotoUpload, "上传图片", () => {
      openFileSelected(
        {
          canSelectFiles: true,
          canSelectFolders: false,
          canSelectMany: true,
          title: "选择需上传的图片文件[支持批量上传]",
          openLabel: "上传",
          filters: {
            图片文件: ["jfif", "pjpeg", "jpg", "jpeg", "pjp", "png"],
          },
        },
        (v: Record<string, any>) => {
          setBox3MapPhoto(v);
        },
        CommandId.map_treeDataMapPhotoRefresh,
      );
    }),
    registerCommand(CommandId.map_preview_model, "预览模型", (modal) => {
      openInternetImage(modal.label, modal.view);
    }),
    registerCommand(CommandId.map_model_view, "查看模型", (modal) => {
      getPackageJson<PackageConfig>("map").then(async (packageJson) => {
        if (packageJson && auth) {
          vscode.env.openExternal(
            vscode.Uri.parse(
              "https://voxa.dao3.fun/?parentType=engine&token=" +
                auth +
                "&modelId=" +
                modal.description +
                "&mapId=" +
                packageJson.id,
            ),
          );
        } else {
          showInformationMessage("请先登录账号或链接地图");
        }
      });
    }),
    registerCommand(
      CommandId.map_model_playerSkin_view,
      "查看玩家皮肤",
      (modal) => {
        getPackageJson<PackageConfig>("map").then(async (packageJson) => {
          if (packageJson && auth) {
            vscode.env.openExternal(
              vscode.Uri.parse(
                "https://voxa.dao3.fun/?parentType=engine&editType=1&token=" +
                  auth +
                  "&modelId=" +
                  modal.modelId +
                  "&mapId=" +
                  packageJson.id,
              ),
            );
          } else {
            showInformationMessage("请先登录账号或链接地图");
          }
        });
      },
    ),
    registerCommand(
      CommandId.map_treeDataMapDataStorageConfig,
      "打开数据空间配置",
      () => {
        openAndWriteTextDocument({
          language: "json",
          content: JSON.stringify(getDataConfig),
          viewColumn: vscode.ViewColumn.Two,
        });
      },
    ),
    registerCommand(
      CommandId.map_preview_dataStorage_value,
      "预览数据空间值",
      async (value) => {
        if (value.key) {
          const isJson = isValidJson(value.tooltip) ? true : false;
          const modifiedDoc = await createTempFile(
            value.tooltip,
            value.key + " - Arena数据空间" + (isJson ? ".json" : ".txt"),
          );
          openTempFileDocument(modifiedDoc);
        }
      },
    ),
    registerCommand(
      CommandId.map_preview_ui_config,
      "预览UI配置",
      async (ui) => {
        const modifiedDoc = await createTempFile(
          ui.tooltip,
          ui.label + " - UI元素配置项.json",
        );
        openTempFileDocument(modifiedDoc, vscode.ViewColumn.Two);
      },
    ),
    registerCommand(CommandId.map_model_rename, "重命名模型", (modal) => {
      renameModel("map", modal);
    }),
    registerCommand(CommandId.map_insertCode_model, "插入模型代码", (modal) => {
      insertCode("mesh/" + modal.label + ".vb");
    }),
    registerCommand(CommandId.map_insertCode_audio, "插入音频代码", (modal) => {
      insertCode("audio/" + modal.label);
    }),
    registerCommand(CommandId.map_insertCode_photo, "插入图片代码", (photo) => {
      insertCode("picture/" + photo.label);
    }),
    registerCommand(
      CommandId.map_insertCode_productMap,
      "插入产品地图代码",
      (product) => {
        insertCode(product.productId);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_playerSkin,
      "插入玩家皮肤代码",
      (playerSkin) => {
        insertCode(playerSkin.label);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_playerSkin_trash,
      "插入玩家皮肤删除代码",
      () => {
        insertCode(`entity.player.clearSkin();`);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_playerSkin_all,
      "插入玩家皮肤所有代码",
      (playerSkin) => {
        insertCode(`entity.player.setSkinByName('${playerSkin.label}');`);
      },
    ),
    registerCommand(CommandId.map_insertCode_voxel, "插入方块代码", (voxle) => {
      insertCode(voxle.label);
    }),
    registerCommand(
      CommandId.map_insertCode_voxel_nameToId,
      "方块名称转ID代码",
      (voxle) => {
        insertCode(`voxels.id('${voxle.label}')`);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_voxel_idToName,
      "方块ID转名称代码",
      (voxle) => {
        insertCode(`voxels.name(${voxle.description})`);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_productMapFullPath,
      "插入产品地图全路径代码",
      (product) => {
        insertCode(`entity.player.openMarketplace([${product.productId}]);`);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_uiFullPath,
      "插入UI全路径代码",
      (ui) => {
        if (typeof ui.type !== "string" || ui.type !== "UiScreen") {
          const editor = vscode.window.activeTextEditor;
          insertCode(
            uiMapTreeDataProvider.generateUiPath(
              ui,
              editor?.document.languageId,
            ),
          );
        } else {
          insertCode(
            `UiScreen.getAllScreen().find(obj => obj.name === '${ui.label}')`,
          );
        }
      },
    ),
    registerCommand(CommandId.map_insertCode_uiPath, "插入UI路径代码", (ui) => {
      if (ui && ui.label) {
        if (ui.type === "UiScreen") {
          insertCode(
            `UiScreen.getAllScreen().find(obj => obj.name === '${ui.label}')`,
          );
        } else if (ui.type === "") {
          insertCode(`findChildByName("${ui.label}")`);
        } else {
          insertCode(
            `findChildByName<${ui.type}>("${ui.label}")`,
            `/**
* ${ui.label}
* @type ${ui.type}
*/
findChildByName("${ui.label}")`,
          );
        }
      }
    }),

    registerCommand(CommandId.file_upLoad, "上传JS文件", upLoadJsFileType),
    registerCommand(CommandId.file_debugger, "快速调试", fastDebugger),

    registerCommand(
      CommandId.map_insertCode_tempChat,
      "插入临时聊天代码",
      (tempChat) => {
        insertCode(tempChat.label);
      },
    ),
    registerCommand(
      CommandId.map_insertCode_expandMap,
      "插入扩展地图代码",
      (expandMap) => {
        insertCode(expandMap.mapId);
      },
    ),
    registerCommand(CommandId.map_preview_photo, "预览图片", (photo) => {
      openInternetImage(photo.label, photo.view);
    }),
    registerCommand(CommandId.map_preview_product, "预览产品", (product) => {
      openInternetImage(product.label, product.view);
    }),
    registerCommand(
      CommandId.map_preview_playerSkin,
      "预览玩家皮肤",
      (playerSkin) => {
        openInternetImage(playerSkin.label, playerSkin.view);
      },
    ),
    registerCommand(CommandId.map_preview_audio, "预览音频", (audio) => {
      openInternetAudio(audio.label, audio.view);
    }),
    registerCommand(CommandId.map_copy_url_audio, "复制音频URL", (audio) => {
      vscode.env.clipboard.writeText(audio.view);
    }),
    registerCommand(CommandId.map_copy_url_photo, "复制图片URL", (photo) => {
      vscode.env.clipboard.writeText(photo.view);
    }),
    registerCommand(CommandId.map_expandMap_view, "查看扩展地图", (map) => {
      vscode.commands.executeCommand(
        CommandId.map_showMap,
        map.editHash,
        map.label.trim(),
      );
    }),
    registerCommand(
      CommandId.map_copy_url_expandMap_play,
      "复制扩展地图游玩端URL",
      (map) => {
        vscode.env.clipboard.writeText(
          apiAndPCType[apiType].pc + "play/" + map.playHash,
        );
      },
    ),

    // 注册文件相关命令。
    registerCommand(CommandId.file_checkDts, "检查Dts", () => checkDts(true)),
    registerCommand(CommandId.file_createProject, "创建项目", createProject),
    registerCommand(CommandId.file_buildNUpload, "构建并上传", buildNUpload),
    registerCommand(CommandId.file_mapTool, "选择地图", selectBox3Map),
    registerCommand(
      CommandId.file_outputName,
      "输出和更新",
      outputAndUpdateShowBar,
    ),
    registerCommand(CommandId.file_openArena, "打开Arena", () => {
      vscode.commands.executeCommand(CommandId.file_workbench);
    }),

    registerCommand(CommandId.file_stopHMR, "停止HMR", stopHMR),
    registerCommand(CommandId.file_stopHMRAll, "停止所有HMR", stopHMRAll),

    registerCommand(CommandId.file_openOutputLog, "打开输出日志", () => {
      OutputChannel.getInstance().show();
    }),
    registerCommand(CommandId.file_dao3config_open, "打开dao3配置", () => {
      openFileDocument("/dao3.config.json");
    }),
    registerCommand(
      CommandId.file_dao3config_open_server,
      "打开dao3配置服务器",
      () => {
        getPathAndFileName2Config().then(async (e) => {
          if (e?.server.path) {
            openFileDocument("/server/" + e?.server.path);
          }
        });
      },
    ),
    registerCommand(
      CommandId.file_webpackconfig_open_client,
      "打开webpack配置客户端",
      () => {
        openFileDocument("/client/webpack.config.js");
      },
    ),
    registerCommand(
      CommandId.file_webpackconfig_open_server,
      "打开webpack配置服务器",
      () => {
        openFileDocument("/server/webpack.config.js");
      },
    ),
    registerCommand(
      CommandId.file_tsconfig_open_server,
      "打开ts配置服务器",
      () => {
        openFileDocument("/server/tsconfig.json");
      },
    ),
    registerCommand(
      CommandId.file_tsconfig_open_client,
      "打开ts配置客户端",
      () => {
        openFileDocument("/client/tsconfig.json");
      },
    ),
    registerCommand(
      CommandId.file_dao3config_open_client,
      "打开dao3配置客户端",
      () => {
        getPathAndFileName2Config().then(async (e) => {
          if (e?.server.path) {
            openFileDocument("/client/" + e?.client.path);
          }
        });
      },
    ),
    registerCommand(CommandId.file_reHMR, "重启HMR", async () => {
      await stopHMR(false);
      await startHMR();
      OutputChannel.getInstance().show();
    }),

    // 注册聊天机器人相关命令。
    registerCommand(CommandId.chatjpt_history, "查看聊天记录", chatjptLogView),

    registerCommand(
      CommandId.chatjpt_onlyKnowledgeBase,
      "查询神岛API知识库内容",
      onlyKnowledgeBase,
    ),
    registerCommand(CommandId.chatjpt_debug, "代码Debug", () =>
      sendCodeToAi("代码Debug", 1),
    ),
    registerCommand(CommandId.chatjpt_optimization, "优化重构", () =>
      sendCodeToAi("优化重构", 2),
    ),
    registerCommand(CommandId.chatjpt_explainDetail, "详细解释", () =>
      sendCodeToAi("详细解释", 3),
    ),
    registerCommand(CommandId.chatjpt_commentGeneration, "注释生成", () =>
      sendCodeToAi("注释生成", 6),
    ),
    registerCommand(
      CommandId.chatjpt_naturalLanguageGenerates,
      "自然语言生成",
      () => sendCodeToAi("自然语言生成", 5),
    ),
    registerCommand(
      CommandId.chatjpt_APIdetailedExplanationsAndExamples,
      "API详细解释和示例",
      () => sendCodeToAi("API详细解释和示例", 8),
    ),
    registerCommand(
      CommandId.chatjpt_generateInspirationAndCreativity,
      "衍生更多灵感和创意",
      () => sendCodeToAi("衍生更多灵感和创意", 9),
    ),
    registerCommand(CommandId.chatjpt_splitKnowledge, "拆分知识点并命题", () =>
      sendCodeToAi("拆分知识点并命题", 10),
    ),
    registerCommand(
      CommandId.chatjpt_fastFunction,
      "快速功能",
      highlightCodeLinesFunction,
    ),
    registerCommand(CommandId.chatjpt_quickFix, "快速修复", (text, fix) => {
      sendCodeToAi(fix, 90, text);
    }),
  );

  // 设置玩家皮肤快捷设置按钮
  bodyParts.forEach((part) => {
    context.subscriptions.push(
      registerCommand(
        CommandId.map_insertCode_playerSkin + `.${part}`,
        "设置玩家皮肤快捷设置按钮",
        (playerSkin) => {
          insertCode(`entity.player.skin.${part} = '${playerSkin.label}';`);
        },
      ),
    );
  });
}

// 通过此函数执行所有已注册的命令。
export function executeAllCommands(): void {
  // 激活扩展的特定上下文状态。
  vscode.commands.executeCommand("setContext", CommandId.ap_activated, true);
}

/**
 * 注册所有操作。
 * @param context VS Code扩展上下文，用于管理扩展的生命周期和订阅事件。
 */
export function registerAllActions(context: vscode.ExtensionContext): void {
  const chatjptConfig = new ChatjptViewModel();
  // 设置 chatjpt 视图对象，以便后续操作可以使用此上下文。
  setChatjptConfig(chatjptConfig);

  context.subscriptions.push(
    // 注册Chat吉PT Web视图。
    vscode.window.registerWebviewViewProvider(
      ChatjptViewModel.viewType,
      chatjptConfig,
      { webviewOptions: { retainContextWhenHidden: true } },
    ),

    // 注册组件代码镜头提供程序
    vscode.languages.registerCodeLensProvider(
      [{ language: "typescript" }],
      new ComponentUsageCodeLensProvider(),
    ),

    // 注册Chatjpt函数快速选择功能
    vscode.languages.registerCodeLensProvider(
      { scheme: "file" },
      new ChatjptFunctionProvider(),
    ),
    // 注册RGB选择颜色快捷功能
    vscode.languages.registerColorProvider(
      { scheme: "file" },
      new RGBAColorProvider(),
    ),
    // 注册RGB选择颜色快捷功能
    vscode.languages.registerColorProvider(
      { scheme: "file" },
      new Vec3ColorProvider(),
    ),
    // 注册RGB选择颜色快捷功能
    vscode.languages.registerColorProvider(
      { scheme: "file" },
      new XMLColorColorProvider(),
    ),
    // 注册daoCfg快速配置功能
    vscode.languages.registerCodeLensProvider(
      { scheme: "file", language: "json" },
      new dao3CfgProvider(),
    ),
    // 将代码动作提供者注册到VS Code的代码动作系统中。
    vscode.languages.registerCodeActionsProvider(
      { scheme: "file" },
      new ChatjptCodeActionProvider(),
    ),
    // 创建输出频道
    OutputChannel.setOutputChannel("ArenaPro").getInstance().getOutputChannel(),
    // 注册Arena地图调试配置提供者
    vscode.debug.registerDebugConfigurationProvider(
      "arena-debugger",
      new ArenaDebugConfigProvider(),
    ),
    vscode.debug.registerDebugConfigurationProvider(
      "arenapro-server-debugger",
      new ArenaProDebugConfigProvider("Server"),
    ),
    vscode.debug.registerDebugConfigurationProvider(
      "arenapro-client-debugger",
      new ArenaProDebugConfigProvider("Client"),
    ),
  );
  // 注册Arena项目数据库树状视图
  storageMap = vscode.window.createTreeView("storageMap", {
    treeDataProvider: storageMapTreeDataProvider,
  });
  // 注册扩展地图树状视图
  expandMap = vscode.window.createTreeView("expandMap", {
    treeDataProvider: mapTreeDataProvider,
  });
  // 注册Arena项目UI界面树状视图
  uiMap = vscode.window.createTreeView("uiMap", {
    treeDataProvider: uiMapTreeDataProvider,
  });
  // 注册Arena项目模型树状视图
  modelsMap = vscode.window.createTreeView("modelsMap", {
    treeDataProvider: modelsMapTreeDataProvider,
  });
  // 注册Arena项目图片树状视图
  photoMap = vscode.window.createTreeView("photoMap", {
    treeDataProvider: photoMapTreeDataProvider,
  });
  // 注册Arena项目音频树状视图
  audioMap = vscode.window.createTreeView("audioMap", {
    treeDataProvider: audioMapTreeDataProvider,
  });
  // 注册Arena项目临时聊天频道树状视图
  tempChatEditMap = vscode.window.createTreeView("tempChatEditMap", {
    treeDataProvider: tempChatEditMapTreeDataProvider,
  });
  // 注册Arena项目商城树状视图
  productMap = vscode.window.createTreeView("productMap", {
    treeDataProvider: productMapTreeDataProvider,
  });
  // 注册Arena项目玩家皮肤树状视图
  playerSkinMap = vscode.window.createTreeView("playerSkinMap", {
    treeDataProvider: playerSkinMapTreeDataProvider,
  });
  // 注册Arena项目方块速查表树状视图
  voxelMap = vscode.window.createTreeView("voxelMap", {
    treeDataProvider: voxelMapTreeDataProvider,
  });

  context.subscriptions.push(
    storageMap,
    expandMap,
    uiMap,
    modelsMap,
    photoMap,
    audioMap,
    tempChatEditMap,
    productMap,
    playerSkinMap,
    voxelMap,
  );
}

// 扩展QuickPickItem接口以包含自定义的command字段
interface ExtendedQuickPickItem extends vscode.QuickPickItem {
  command?: CommandId; // 方便选择该项时调用命令
}

// 工具条项目定义分离出来，便于管理和可能的扩展
export const userCenterToolItems: ExtendedQuickPickItem[] = [
  {
    label: "$(accounts-view-bar-icon) 登录神岛账号",
    command: CommandId.userCenterTool_setting,
  },
  {
    label: "$(log-out) 退出登录",
    command: CommandId.userCenterTool_accountsLogout,
  },
  {
    label: "快捷功能",
    kind: vscode.QuickPickItemKind.Separator,
  },
  {
    label: "$(notebook) 方块速查表",
    command: CommandId.map_treeDataMapVoxelSearch,
  },
  {
    label: "$(server-environment) 神岛NPM包",
    command: CommandId.file_npm_package_get,
  },
  {
    label: "$(notebook-kernel-select) 地图游玩数据",
    command: CommandId.map_playData,
  },
  {
    label: "帮助文档",
    kind: vscode.QuickPickItemKind.Separator,
  },
  {
    label: "$(notebook) 神岛API文档",
    command: CommandId.userCenterTool_api_help,
  },
  {
    label: "$(notebook) 插件帮助文档",
    command: CommandId.userCenterTool_arenaPro_Help,
  },
  {
    label: "插件配置",
    kind: vscode.QuickPickItemKind.Separator,
  },
  {
    label: "$(settings-gear) NodeJs相关",
    command: CommandId.file_nodeJs_setting,
  },
  {
    label: "$(settings-gear) Chat吉PT",
    command: CommandId.chatjpt_setting,
  },
];
